home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWWindow / Include / FWWindow.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  9.2 KB  |  328 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWWindow.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9. //    FW_CWindow: Wrapper for a ODWindow.
  10. //    
  11. //        Every FW_CFrame object has a FW_CWindow object associated with it. When 
  12. //        FW_CFrame::FacetAdded (not FrameAdded) is called, a new FW_CWindow object is created 
  13. //        if the frame doesn't already have one. The FW_CWindow is automatically deleted when
  14. //        FW_CFrame::FrameRemoved is called.
  15. //
  16. //        You should never directly create a FW_CWindow, ODF will create it for you.
  17. //
  18. #ifndef FWWINDOW_H
  19. #define FWWINDOW_H
  20.  
  21. // ----- OS Includes -----
  22.  
  23. #ifndef FWRECT_H
  24. #include "FWRect.h"
  25. #endif
  26.  
  27. #ifndef FWGRDEF_H
  28. #include "FWGrDef.h"
  29. #endif
  30.  
  31. // ----- Foundation Layer -----
  32.  
  33. #ifndef FWAUTODE_H
  34. #include "FWAutoDe.h"
  35. #endif
  36.  
  37. #ifndef FWRUNTYP_H
  38. #include "FWRunTyp.h"
  39. #endif
  40.  
  41. // ----- OpenDoc Includes -----
  42.  
  43. #ifndef _ODTYPES_
  44. #include <ODTypes.h>
  45. #endif
  46.  
  47. #ifndef SOM_ODWindow_xh
  48. #include <Window.xh>
  49. #endif
  50.  
  51. #if FW_LIB_EXPORT_PRAGMAS
  52. #pragma lib_export on
  53. #endif
  54.  
  55. //========================================================================================
  56. //    Forward Declarations
  57. //========================================================================================
  58.  
  59. class    FW_CLASS_ATTR ODFrame;
  60. class     FW_CLASS_ATTR FW_CString;
  61. class     FW_CLASS_ATTR FW_CGraphicDevice;
  62. struct    FW_CLASS_ATTR WindowProperties;
  63. class     FW_CLASS_ATTR FW_CMacWindowEvent;
  64. class    FW_CLASS_ATTR ODSession;
  65.  
  66. //========================================================================================
  67. //    Window style constants
  68. //========================================================================================
  69.  
  70. #define FW_kStandardWindow        0x00000001
  71. #define FW_kOverlappedWindow    0x00000002
  72. #define FW_kFloatingWindow        0x00000004
  73. #define FW_kModelessDialog        0x00000008
  74. #define FW_kModalDialog            0x00000010
  75.     
  76. #define FW_kSystemDialog        0x00000020
  77. #define FW_kResizeable            0x00000040
  78. #define FW_kHasCaption            0x00000080
  79. #define FW_kHasCloseBox            0x00000100
  80. #define FW_kHasMaximizeBox        0x00000200
  81. #define FW_kHasMinimizeBox        0x00000400
  82.     
  83. //#define FW_kNoStyleWindow         0
  84. #define FW_kMaximized             0x00001000
  85. #define FW_kMinimized             0x00002000
  86.  
  87. //#ifdef FW_BUILD_MAC
  88. //#define FW_kMacDesktopPane        0x00004000
  89. //#endif
  90.  
  91. // Standard document window
  92.  
  93. #ifdef FW_BUILD_MAC
  94. #define FW_kDocumentWindow        FW_kStandardWindow | FW_kResizeable | FW_kHasCloseBox | FW_kHasMaximizeBox | FW_kHasMinimizeBox
  95. #else
  96. // Note - OpenDoc on Windows creates the Shell window for us so and the our window is a child 
  97. // of the shell window. The result is that we don't need any of the adornment that go on a 
  98. // standard overlapped window.
  99. #define FW_kDocumentWindow        FW_kStandardWindow
  100. #endif
  101.  
  102. //========================================================================================
  103. //    class FW_CWindow
  104. //========================================================================================
  105.  
  106. class FW_CLASS_ATTR FW_CWindow
  107. {
  108. public:
  109.     FW_DECLARE_CLASS
  110.  
  111. public:
  112.     typedef unsigned long WindowStyle;
  113.     
  114. //----------------------------------------------------------------------------------------
  115. //    Constructors/Destructor
  116. //
  117. public:
  118.     
  119.     FW_CWindow(Environment* ev, 
  120.                 ODPart* thePart,
  121.                 ODTypeToken viewType,
  122.                 ODTypeToken presentation,
  123.                 const FW_CPoint& interiorSize,        // in pixels
  124.                 const FW_CPoint& position,            // in pixels
  125.                 WindowStyle style);
  126.         // for document window
  127.                 
  128.     FW_CWindow(Environment* ev, 
  129.                 ODPart* thePart,
  130.                 ODFrame* parentFrame,
  131.                 FW_Boolean    persistent,
  132.                 ODTypeToken viewType,
  133.                 ODTypeToken presentation,
  134.                 const FW_CString& defaultTitle,
  135.                 const FW_CPoint& interiorSize,        // in pixels
  136.                 const FW_CPoint& position,            // in pixels
  137.                 WindowStyle style);
  138.         // for View As Window
  139.                 
  140.     FW_CWindow(Environment* ev, 
  141.                 ODPart* thePart,
  142.                 ODFrame* odFrame);
  143.         // Creates a window from a frame
  144.                 
  145.     FW_CWindow(Environment* ev, 
  146.                 ODPart* thePart, 
  147.                 ODID windowID);
  148.         // Create a window for non-root frame
  149.                 
  150.     virtual ~FW_CWindow();
  151.  
  152. //----------------------------------------------------------------------------------------
  153. //    From ODWindow (inlines)
  154. //
  155. public:
  156.     FW_Boolean                    IsActive(Environment *ev) const;
  157.     ODPlatformWindow            GetPlatformWindow(Environment *ev) const;
  158.  
  159.     void                        Select(Environment *ev) const;
  160.  
  161.     FW_Boolean                    IsFloating(Environment* ev) const;
  162.  
  163.     void                        Close(Environment *ev);
  164.     void                        CloseAndRemove(Environment *ev);
  165.  
  166.     ODID                        GetID(Environment *ev) const;
  167.  
  168.     void                        Show(Environment* ev);
  169.     void                         Hide(Environment* ev);
  170.     FW_Boolean                     IsShown(Environment* ev) const;
  171.  
  172. //----------------------------------------------------------------------------------------
  173. //    New API
  174. //
  175. public:
  176.     ODWindow*                    AcquireODWindow(Environment *ev) const;
  177.     
  178.     // ----- Show/Hide -----
  179.     void                        ShowHide(Environment* ev, 
  180.                                     FW_Boolean state);
  181.     
  182.     // ----- Graphic Device -----
  183.     FW_CGraphicDevice*            GetGraphicDevice(Environment* ev) const;
  184.     
  185.     // ----- Window Title -----
  186.     void                        GetWindowTitle(Environment* ev, 
  187.                                     FW_CString& windowTiltle) const;
  188.     void                        SetWindowTitle(Environment* ev, 
  189.                                     const FW_CString& windowTiltle);
  190.     
  191.     // ----- Window Geometry -----
  192.     void                        SetWindowSize(Environment* ev, 
  193.                                     const FW_CPoint& interiorSize);
  194.     void                        SetWindowPosition(Environment* ev,
  195.                                     const FW_CPoint& newPosition);
  196.     
  197.     void                        GetWindowSize(Environment* ev, 
  198.                                     FW_CPoint& interiorSize) const;
  199.     void                        GetWindowPosition(Environment* ev, 
  200.                                     FW_CPoint& position) const;
  201.                                     
  202.     void                        GetBorderSize(Environment* ev,
  203.                                     FW_CRect& borderSize) const;
  204.     
  205.     void                        FitToScreen(Environment* ev);
  206.     
  207.     // ----- Coordinate Conversion -----
  208.     void                        WindowToScreen(Environment* ev,
  209.                                     FW_CPoint* points, 
  210.                                     unsigned short nbPoint = 1);
  211.     void                        ScreenToWindow(Environment* ev,
  212.                                     FW_CPoint* points, 
  213.                                     unsigned short nbPoint = 1);
  214.  
  215.     void                        WindowToScreen(Environment* ev,
  216.                                     FW_CRect& rect);
  217.     void                        ScreenToWindow(Environment* ev,
  218.                                     FW_CRect& rect);
  219.                                     
  220.     // ----- Frame Activation -----
  221.     virtual void                HideShowOnActivate(Environment* ev, 
  222.                                     FW_Boolean state);
  223.  
  224. //----------------------------------------------------------------------------------------
  225. //    Internal Only
  226. //
  227. public:
  228. #ifdef FW_BUILD_MAC    
  229.     // ----- Mac Window resizing tracking -----
  230.     void                        PrivMacTrackResizeWindow(Environment* ev, 
  231.                                     const FW_CRect& growLimits, 
  232.                                     const FW_CMacWindowEvent& windowEvent);
  233.                                     
  234.     // ----- Mac Window Zooming -----
  235.     void                        PrivMacDoZoom(Environment* ev, 
  236.                                     const FW_CPoint& zoomedSize, 
  237.                                     const FW_CRect& borderSize,
  238.                                     const FW_CRect& screenRect,
  239.                                     unsigned long message);
  240.                                     
  241.     // ----- Mac Window creation -----
  242.     ODPlatformWindow            PrivMacCreatePlatformWindow(Environment* ev, 
  243.                                     Str255 windowTitle,
  244.                                     const FW_CPoint& interiorSize,
  245.                                     const FW_CPoint& position,
  246.                                     unsigned short procID,
  247.                                     FW_Boolean hasCloseBox);
  248. #endif
  249.  
  250. #ifdef FW_BUILD_MAC
  251.     static unsigned short         PrivMacStyleToProcId(Environment *ev,
  252.                                     WindowStyle style);
  253. #endif
  254.  
  255. #ifdef FW_BUILD_WIN
  256.     static DWORD                PrivWindStyleToWindowsFlags(WindowStyle style);
  257.     static void                    PrivWindFixSystemMenu(WindowStyle style);
  258. #endif
  259.  
  260.     // ----- Window information -----                                
  261.     static void                    PrivGetBorderSize(ODPlatformWindow platformWindow,
  262.                                     FW_CRect& borderSize);
  263.  
  264. protected:
  265.     // ----- ODWindow creation -----
  266.     void                        PrivCreateODWindow(Environment* ev, 
  267.                                     ODPart* thePart,
  268.                                     ODFrame* parentFrame,
  269.                                     FW_Boolean    persistent,
  270.                                     ODTypeToken viewType,
  271.                                     ODTypeToken presentation,
  272.                                     const FW_CString& windowTitle,
  273.                                     const FW_CPoint& interiorSize,
  274.                                     const FW_CPoint& position,
  275.                                     WindowStyle style);
  276.  
  277.     void                        PrivCreateODWindowForFrame(Environment* ev, 
  278.                                     ODPart* odPart,
  279.                                     ODFrame* odFrame);
  280.     
  281.     void                        PrivGetDocumentName(Environment* ev, 
  282.                                     ODFrame* sourceFrame, 
  283.                                     FW_CString& title);
  284.  
  285. //----------------------------------------------------------------------------------------
  286. //    Data Members
  287. //
  288. protected:
  289.     ODID                fWindowID;
  290.     ODSession*            fSession;
  291.     
  292.     FW_CPoint            fWindowSize;
  293.     FW_CPoint            fWindowPosition;
  294.     
  295. private:
  296.     FW_CGraphicDevice*    fGraphicDevice;
  297.     
  298. #ifdef FW_BUILD_MAC
  299.     static Handle         gMacFloatWindowProc;
  300. #endif
  301. };
  302.  
  303. //========================================================================================
  304. //    Inlines
  305. //========================================================================================
  306.  
  307. //----------------------------------------------------------------------------------------
  308. // FW_CWindow::ShowHide
  309. //----------------------------------------------------------------------------------------
  310. inline void FW_CWindow::ShowHide(Environment* ev, FW_Boolean state)
  311. {
  312.     state ? Show(ev) : Hide(ev);
  313. }
  314.  
  315. //----------------------------------------------------------------------------------------
  316. // FW_CWindow::GetID
  317. //----------------------------------------------------------------------------------------
  318. inline ODID FW_CWindow::GetID(Environment* ev) const
  319. {
  320.     return fWindowID;
  321. }
  322.  
  323. #if FW_LIB_EXPORT_PRAGMAS
  324. #pragma lib_export off
  325. #endif
  326.  
  327. #endif
  328.